import type {App, Plugin} from "vue"

export type SFCWithInstall<T> = T & Plugin
export const withInstall = <T>(comp: T): SFCWithInstall<T> => {
    (comp as SFCWithInstall<T>).install = (app: App) => {
        // 所以要加上这个条件
        const name = (comp as any).name || (comp as any).__name
        //注册组件
        app.component(name, comp as SFCWithInstall<T>)
    }
    return comp as SFCWithInstall<T>
}